// -*- coding: utf-8 -*-
// 引入依赖包
// 最低SDK版本要求：imageenhan20190930的SDK版本需大于等于1.0.12。
// 可以在此仓库地址中引用最新版本SDK：https://mvnrepository.com/artifact/com.aliyun/imageenhan20190930
// <dependency>
//       <groupId>com.aliyun</groupId>
//       <artifactId>imageenhan20190930</artifactId>
//       <version>${aliyun.imageenhan.version}</version>
// </dependency>

import com.aliyun.imageenhan20190930.models.GenerateImageWithTextAndImageResponse;
import com.aliyun.tea.TeaException;
import com.aliyun.tea.TeaModel;

public class GenerateImageWithTextAndImage {
    public static com.aliyun.imageenhan20190930.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // 必填，您的 AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 必填，您的 AccessKey Secret
                .setAccessKeySecret(accessKeySecret);
        // 访问的域名
        config.endpoint = "imageenhan.cn-shanghai.aliyuncs.com";
        return new com.aliyun.imageenhan20190930.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        // "YOUR_ACCESS_KEY_ID", "YOUR_ACCESS_KEY_SECRET" 的生成请参考https://help.aliyun.com/document_detail/175144.html
        // 如果您是用的子账号AccessKey，还需要为子账号授予权限AliyunVIAPIFullAccess，请参考https://help.aliyun.com/document_detail/145025.html
        com.aliyun.imageenhan20190930.Client client = GenerateImageWithTextAndImage.createClient(
                "LTAIBqFbkm0FZ1K6",
                "1inhunDMjbB7nsDvac2vI1JtPaRjBn");
        String ref1 = "https://passon.oss-cn-shanghai.aliyuncs.com/imagegen/wax1.jpeg";
        String ref2 = "https://passon.oss-cn-shanghai.aliyuncs.com/imagegen/wax2.jpeg";
        String ref3 = "https://passon.oss-cn-shanghai.aliyuncs.com/imagegen/wax3.jpg";
        String ref4 = "https://viapi-test.oss-cn-shanghai.aliyuncs.com/yxrtest/%E6%96%87%E7%94%9F%E5%9B%BE/%E7%9D%A1%E8%8E%B2.jpg";
        com.aliyun.imageenhan20190930.models.GenerateImageWithTextAndImageRequest generateImageWithTextAndImageRequest = new com.aliyun.imageenhan20190930.models.GenerateImageWithTextAndImageRequest()
                .setRefImageUrl(ref1)
                .setText("彩虹")
                .setNumber(1)
                .setAspectRatioMode("center_crop")
                .setResolution("1024*1024")
                .setSimilarity(0.2F);
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            GenerateImageWithTextAndImageResponse generateImageWithTextAndImageResponse = client.generateImageWithTextAndImageWithOptions(generateImageWithTextAndImageRequest, runtime);
            // 获取整体结果。
            System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(generateImageWithTextAndImageResponse)));
            // 获取单个字段。
//            System.out.println(generateImageWithTextAndImageResponse.getBody());
        } catch (TeaException teaException) {
            // 获取整体报错信息。
            System.out.println(com.aliyun.teautil.Common.toJSONString(teaException));
            // 获取单个字段。
            System.out.println(teaException.getCode());
        }
    }
}